/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mb.webserver.handler;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import mb.mbmiddle.MbPartMiddle;
import mb.webserver.inMemory.NewsDataProcess;
import mb.webserver.inMemory.PromotionDataProcess;
import mb.webserver.inMemory.ServiceDetailProcess;

/**
 *
 * @author thanh.nguyenchi
 */
public class StockData extends BaseServlet{   
    
    public StockData(){
        super();        
    }
    
    @Override
    public void doGet(HttpServletRequest request,HttpServletResponse response)
        throws ServletException,IOException
    {         
    ///api/loadServieDetail?version={1}&lang={2}&serviceId=20&callback=
        String sOut = "";       
        String version          = request.getParameter("version");              // check 
        String lang             = request.getParameter("lang");                 // log
        String cateId           = request.getParameter("cateid");               // log
        String page             = request.getParameter("page");                 // log
        String callback         = request.getParameter("callback");             // check 
        
        StringBuffer sbLog = new StringBuffer();
        sbLog.append("NewsData ==> [v:" + version);
        sbLog.append("] [i:" + lang + "] sId:[" + cateId);
        sbLog.append("] [p:" + page + "]");
        sbLog.append("] [c:" + callback + "] from [ip:" + request.getRemoteAddr() + "]");
        log(sbLog.toString());
        
        sOut = "[{\"Symbol\":\"AAM \",\"StockName\":\"CTCP THUY SAN MEKONG \"}" +
                ",{\"Symbol\":\"ABI \",\"StockName\":\"CTCP Bao hiem NH Nong Nghiep Viet Nam \"}" +
                ",{\"Symbol\":\"ABT \",\"StockName\":\"CTCP XNK THUY SAN BEN TRE \"}" +
                ",{\"Symbol\":\"ACE \",\"StockName\":\"CTCP Be tong Ly tam An Giang \"}" +
                ",{\"Symbol\":\"ACL \",\"StockName\":\"CTCP XNK T.SAN CL-AG \"}" +
                ",{\"Symbol\":\"ADP \",\"StockName\":\"CTCP Son A Dong \"}" +
                ",{\"Symbol\":\"AGC \",\"StockName\":\"CTCP ca phe An Giang \"}" +
                ",{\"Symbol\":\"AGD \",\"StockName\":\"CTCP GO DANG \"}" +
                ",{\"Symbol\":\"AGF \",\"StockName\":\"CTCP XNK THUY SAN ANGIANG \"}" +
                ",{\"Symbol\":\"AGM \",\"StockName\":\"CTCP XNK AN GIANG \"}" +
                ",{\"Symbol\":\"AGR \",\"StockName\":\"CTCPCK NHNN & PTNT VN \"}" +
                ",{\"Symbol\":\"ALP \",\"StockName\":\"CT CP ANPHANAM \"}" +
                ",{\"Symbol\":\"ANV \",\"StockName\":\"CT CP NAM VIET \"}" +
                ",{\"Symbol\":\"APC \",\"StockName\":\"CTCP CHIEU XA AN PHU \"}" +
                ",{\"Symbol\":\"ASM \",\"StockName\":\"CT DTXD SAO MAI AN GIANG \"}" +
                ",{\"Symbol\":\"ASP \",\"StockName\":\"CTCP DAU KHI AN PHA S.G \"}" +
                ",{\"Symbol\":\"ATA \",\"StockName\":\"CTCP NTACO \"}" +
                ",{\"Symbol\":\"AVF \",\"StockName\":\"CTCP VIET AN \"}" +
                ",{\"Symbol\":\"AVS \",\"StockName\":\"CTCP Chung khoan Au Viet \"}" +
                ",{\"Symbol\":\"BAS \",\"StockName\":\"CTY CP BASA \"}" +
                ",{\"Symbol\":\"BBC \",\"StockName\":\"CTY CP BANH KEO BIEN HOA \"}]";
        
        response.setContentType("application/json; charset=UTF-8"); 
        response.setStatus(HttpServletResponse.SC_OK);
        response.getWriter().println(sOut);
    }
    
    private boolean hasService(String cateId){
        try{
            boolean flag = MbPartMiddle.objDbConfig.checkService(new Long(cateId));
            return flag;
        }
        catch (Exception ex){
            return false;
        }
    }
}
